//
//  MasterController.swift
//  BodyBuilding
//
//  Created by franze on 2017/9/30.
//  Copyright © 2017年 franze. All rights reserved.
//

import UIKit

class MasterController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        controllersConfig()
    }
    
    func controllersConfig(){
        view.backgroundColor = UIColor.white
        
        let club = ClubController()
        let clubNav = UINavigationController(rootViewController: club)
        
        let teacher = TeacherController()
        let teacherNav = UINavigationController(rootViewController: teacher)
        
        let sharing = SharingController()
        let sharingNav = UINavigationController(rootViewController: sharing)
        
        let me = MeController()
        let meNav = UINavigationController(rootViewController: me)
        
        let controllers = [clubNav,teacherNav,sharingNav,meNav]
        viewControllers = controllers
        
        for controller in viewControllers as! [UINavigationController]{
            controller.isNavigationBarHidden = true
        }
        
        var index:Int = 0
        let tabBarItemTitle = ["俱乐部","大师","晒图","训练"]
        let tabBarItemImg = ["club","teacher","sharing","training"]
        for item in tabBar.items! {
            var size = CGSize(width: 22, height: 22)
            if index == 1{
                size = CGSize(width: 22, height: 26)
            }
            let selectImg = UIImage(named: "\(tabBarItemImg[index])"+"_select")
            let unselectImg = UIImage(named: "\(tabBarItemImg[index])"+"_unselect")
            item.title = tabBarItemTitle[index]
            item.selectedImage = selectImg?.scaleImageToSize(size).withRenderingMode(.alwaysOriginal)
            item.image = unselectImg?.scaleImageToSize(size).withRenderingMode(.alwaysOriginal)
            item.setTitleTextAttributes([NSAttributedStringKey.font : UIFont.systemFont(ofSize: 12)], for: .normal)
            index += 1
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}
